package com.atguigu.dga.governance.service.impl;

import com.atguigu.dga.governance.bean.GovernanceMetric;
import com.atguigu.dga.governance.mapper.GovernanceMetricMapper;
import com.atguigu.dga.governance.service.GovernanceMetricService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 考评指标参数表 服务实现类
 * </p>
 *
 * @author tubage
 * @since 2024-03-16
 */
@Service
@DS("dga")
public class GovernanceMetricServiceImpl extends ServiceImpl<GovernanceMetricMapper, GovernanceMetric> implements GovernanceMetricService {
    @Autowired
    GovernanceMetricMapper governanceMetricMapper;
    @Override
    public GovernanceMetric createMetric(GovernanceMetric metricDTO) {
        governanceMetricMapper.insert(metricDTO);
        return metricDTO;
    }

    @Override
    public List<GovernanceMetric> getMetricByCode(String metricCode) {
        ArrayList<GovernanceMetric> governanceMetrics = new ArrayList<>();
        GovernanceMetric governanceMetric = governanceMetricMapper.selectByCode(metricCode);
        governanceMetrics.add(governanceMetric);
        return governanceMetrics;
    }

    @Override
    public String disableOrNotMetric(String metricCode, Long isDisabled) {
        governanceMetricMapper.disableByCode( metricCode,  isDisabled);
        return "success";
    }

    @Override
    public void deleteByMetricCode(String metricCode) {
        governanceMetricMapper.deleteByMetricCode(metricCode);
    }

    @Override
    public String updateMetricByCode(GovernanceMetric metricDTO) {
        governanceMetricMapper.updateMetricByCode(metricDTO);
        return "success";
    }
}
